<?php
namespace app\login\controller;
use think\Controller;
use think\Request;
use \think\Db;
class Login extends \app\api\controller\Base
{
      public function _initialize() {
        parent::_initialize ();
      }

    /**
     * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     * 小程序
     * */

    public function getcode(){
       $data = $this->data;
       $check = $this->validate($data,'Login.code');
       if($check !==true){
         return api_return($check);
       }
       $res = model("login")->getCode($data);
       if($res !=false){
          return api_return('10002',$res);
       }else{
          return api_return(-10002);
       }
    }

    /***
     * 小程序登陆获取用户授权信息
     * @param int $web_id
     * @return bool
     */
    public function getuserinfo(){


       $data = $this->data;
       $check = $this->validate($data,'login.user');

       if($check !==true){
         return api_return($check);
       }
       $res = model("Login")->getuserinfo($data);

       if($res !=false && $res >0){
          return api_return('10002',$res);
       }else{
          return api_return($res);
       }


            // dump($check);die;
    }

    /**
     * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     * 公众号
     * */

}
